#ifndef _RTC85163_H_
#define _RTC85163_H_

#include "rtctime.h"
#include "swiic.h"

#ifdef   _RTC_MOUDEL_
#define  RTC_EXT
#else
#define  RTC_EXT  extern
#endif

#include <stdint.h>

#define RTC_CHIP_ADDR_WRITE       0xA2
#define RTC_CHIP_ADDR_READ        0xA3
#define RTC_CHIP_ADDR             0xA2

#define RTC_SUBA_ADDR_CON_1       0x00 
#define RTC_SUBA_ADDR_CON_2       0x01
#define RTC_SUBA_ADDR_CON_OUT     0x0D 

#define RTC_SUBA_ADDR_TIME_SEC    0x02 			  
#define RTC_SUBA_ADDR_TIME_MIN    0x03 			  
#define RTC_SUBA_ADDR_TIME_HOUR   0x04 			  
#define RTC_SUBA_ADDR_TIME_DAY    0x05 			  
#define RTC_SUBA_ADDR_TIME_WEEK   0x06 			  
#define RTC_SUBA_ADDR_TIME_MON    0x07 			  
#define RTC_SUBA_ADDR_TIME_YEAR   0x08 			  

#define RTC_SUBA_ADDR_ALARM_MIN   0x09
#define RTC_SUBA_ADDR_ALARM_HOUR  0x0A
#define RTC_SUBA_ADDR_ALARM_DAY   0x0B
#define RTC_SUBA_ADDR_ALARM_WEEK  0x0C 

#define RTC_SUBA_ADDR_TIMER_CON   0x0E 
#define RTC_SUBA_ADDR_TIMER_REG   0x0F 

#define CON_1_TEST1_POS           7
#define CON_1_STOP_POS			  5
#define CON_1_TESTC_POS			  3

#define CON_1_TEST1_MASK          (1 << 7)		  
#define CON_1_STOP_MASK			  (1 << 5)		  
#define CON_1_TESTC_MASK		  (1 << 3)		  

#define CON_2_TITP_POS            4
#define CON_2_AF_POS              3
#define CON_2_TF_POS              2
#define CON_2_AIE_POS             1
#define CON_2_TIE_POS             0

#define CON_2_TITP_MASK           (1 << 4)		  
#define CON_2_AF_MASK             (1 << 3)		  
#define CON_2_TF_MASK             (1 << 2)		  
#define CON_2_AIE_MASK            (1 << 1)		  
#define CON_2_TIE_MASK            (1 << 0)		  

#define CON_OUT_FE_MASK			  (1 << 7)
#define CON_OUT_FD_MASK           (0x03)

#define CON_TIMER_CON_TE_MASK     (1 << 7)
#define CON_TIMER_CON_TD_MASK     (0x03)    

#define TIME_SEC_VL_MASK          (1 << 7)		  
#define TIME_MON_C_MASK           (1 << 7)        

#define FLAG_LEAP_YEAR            1
#define FLAG_NONLEAP_YEAR         0  

void PFC8563_start(const iic_obj_type * iic);
void PFC8563_stop(const iic_obj_type * iic);
void PFC8563_get_time(const iic_obj_type * iic, TIME_Type *RtcTime);
void PFC8563_set_time(const iic_obj_type * iic, TIME_Type *RtcTime);

#undef 	RTC_EXT
#endif
